import Vue from "vue";
import Vuex from "vuex";
import { toggleClass } from "@/util/index";

const devThemeColor = localStorage.getItem("option-theme");
devThemeColor&&toggleClass(document.body, "custom-" + devThemeColor);

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    themeColor: devThemeColor || "20a0ff", // 默认为20a0ff文件的主题
  },
  mutations: {
    //更新主题颜色
    setThemeColor(state, curcolor) {
      state.themeColor = curcolor;
      localStorage.setItem("option-theme", curcolor);
      toggleClass(document.body, "custom-" + curcolor);
    },
  },
});
export default store;
